using System.Collections;
using UnityEngine;

public class Ticker : MonoBehaviour
{
	public string url = string.Empty;

	public float speed = 8f;

	private TextMesh tMesh;

	private Transform tr;

	private int textLength;

	private void Start()
	{
		StartCoroutine(Check());
	}

	private IEnumerator Check()
	{
		WWW www = new WWW(url);
		tr = base.transform;
		tMesh = base.gameObject.GetComponent<TextMesh>();
		yield return www;
		if (www.error == null)
		{
			if (www.text.Length < 250)
			{
				tMesh.text = www.text;
			}
			textLength = tMesh.text.Length;
			www.Dispose();
		}
		else
		{
			textLength = 0;
			tMesh.text = string.Empty;
		}
	}

	private void Update()
	{
		if (textLength > 0)
		{
			Transform transform = tr;
			Vector3 position = tr.position;
			float x = position.x - Time.smoothDeltaTime * speed;
			Vector3 position2 = tr.position;
			float y = position2.y;
			Vector3 position3 = tr.position;
			transform.position = new Vector3(x, y, position3.z);
			Vector3 position4 = tr.position;
			if (position4.x < -75f - (float)textLength * 1.5f)
			{
				tr.position = new Vector3(68f, 36.5f, 60f);
			}
		}
	}
}
